package com.wxy.care.controller;

import com.wxy.care.common.R;
import com.wxy.care.entity.Falldown;
import com.wxy.care.service.FalldownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/falldown")
public class FalldownController {
    @Autowired
    private FalldownService falldownService;
    @GetMapping()
    public R<String> FallDetect(String houseName,String slaveId,Boolean flag){
        return falldownService.fallDownSet(houseName,slaveId,flag) ? R.success("success") :R.error("error");
    }
    @GetMapping("/getall")
    public R<List<Falldown>> getAll(){
        return R.success(falldownService.list());
    }

    @GetMapping("/isFalldown")
    public R<Boolean>isFalldown (String houseName){
        return R.success(falldownService.isFalldown(houseName));
    }
}
